package uk.org.landeg.euler.problems;

import java.util.Set;

import uk.org.landeg.euler.problems.framework.AbstractProblem;
import uk.org.landeg.euler.problems.framework.ProblemLauncher;
import uk.org.landeg.euler.problems.lib.PrimeLib;

public class Problem069 extends AbstractProblem {

	public static void main(String[] args) {
		ProblemLauncher launcher = new ProblemLauncher(new Problem069());
		launcher.solve();
	}

	@Override
	public String getDescription() {
		return "Find the value of n  1,000,000 for which n/φ(n) is a maximum";
	}

	@Override
	public Integer getProblemNumber() {
		// TODO Auto-generated method stub
		return 69;
	}

	@Override
	public Object solve() {
		notes.add("Solved on pure faith!  find the product of all primes 2..n where P(2..n) < 1000000");
		notes.add("Surprisingly gives the right answer!");
		Set<Integer> primes = PrimeLib.seqPrimes((int)(Math.sqrt(1000000)));
		long prod= 1;
		for (Integer prime : primes) {
			if (prod * prime < 1000000) { 	
				prod *= prime;
			} else {
				break;
			}
		}
		return prod;
	}

}
